import java.util.Random;
import java.util.Scanner;

public class test {
    /*1到100出现9的次数
    public static int countNine(){
        int count=0;
        for (int i = 1; i < 100; i++) {
            if(i%10==9){
                count++;
            }
            else if(i/10==9){
                count++;
            }
        }
        return count;
    }
    public static void main(String[] args) {
  int ret=countNine();
        System.out.println(ret);
    }*/

//打印X图形
   /* public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n= scan.nextInt();
            for (int i = 0; i < n; i++) {
                for(int j=0;j<n;j++){
                    if(i==j||(j+i==n-1)){
                        System.out.print("*");
                    }
                    else{
                        System.out.print(" ");
                    }
                }
                System.out.println();
            }

    }
*/


//123倒着输出每一位
  /* public static void func(int n){   且不用写输入函数
       while(n!=0){
           System.out.println(n%10);
           n/=10;
       }
   }
    public static void main(String[] args) {
        //System.out.println(func());这样写相当于打印func
       func(123);
    }
*/


//计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值
   /* public static double func() {   //这里依旧使用func函数
        double sum = 0;
        int flg = 1;
        for (int i = 1; i <= 100; i++) {
            sum += 1.0 / i*flg;
            flg = -flg;
        }
        return sum;
    }

    public static void main(String[] args) {
        System.out.println(func());//打印func可以出内容就是因为上述中return sum返回的是sum的值
    }
}*/


//模拟登陆输入密码
      /*  public static int login () {  //login是登录的意思
            int count = 3;
            Scanner scan = new Scanner(System.in);
            System.out.println("请输入你的密码：");
            while (count != 0) {
                String password = scan.nextLine(); //输入内容的代码且要与Scanner后面的变量名字相同
                if (password.equals("123456")) {      //在java中比较字符串是equals()
                    System.out.println("输入成功");
                    break;
                } else {
                    count--;
                    System.out.println("你还有" + count + "次机会");
                }
            }
            return 0;
        }
    public static void main(String[] args) {
        login();   相当于 System.out.println(login())但是后者写法是错误的

    }

*/



/*
//猜数字游戏
        public static void main(String[] args) {
            Random random = new Random(); // 默认随机种子是系统时间
            Scanner sc = new Scanner(System.in);
            int toGuess = random.nextInt(100);
// System.out.println("toGuess: " + toGuess);
            while (true) {
                System.out.println("请输入要输入的数字: (1-100)");
                int num = sc.nextInt();
                if (num < toGuess) {
                    System.out.println("低了");
                } else if (num > toGuess) {
                    System.out.println("高了");
                } else {
                    System.out.println("猜对了");
                    break;
                }
            }
            sc.close();
        }
    }
*/


//java中方法的重载在c中叫函数
    /*public static int add(int a,int b){
        return a+b;
    }
    public static double add(double a,double b){
        return a+b;
    }
    public static void main(String[] args) {
        int ret=add(1,2);
        System.out.println(ret);
        double ret1=add(1,2);
        System.out.println(ret1);
    }
}*/
